package com.itcam.cm.user.controller;


import com.itcam.cm.user.utils.HttpUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

public class TestSms {

    public static void main(String[] args) {
        String host = "https://zwp.market.alicloudapi.com";
        String path = "/sms/sendv2";
        String method = "GET";
        String appcode = "6e125298cf0e49a3805302957b2fef4f";
        Map<String, String> headers = new HashMap<String, String>();
        headers.put("Authorization", "APPCODE " + appcode);
        Map<String, String> querys = new HashMap<String, String>();
        String phone = "13826837320";
        querys.put("mobile", phone);
        String validateCode = RandomStringUtils.randomNumeric(4);
        querys.put("content", "【智能云】您的验证码是"+validateCode+"。如非本人操作，请忽略本短信");
        System.out.println("【智能云】您的验证码是"+validateCode+"。如非本人操作，请忽略本短信");

        try {
            HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);
            System.out.println(response.toString());
            //获取response的body
            System.out.println(EntityUtils.toString(response.getEntity()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
